package swing;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.AbstractTableModel;

public class SwingTableSimpleExample extends JFrame{
	
	
	class MyTableModel extends AbstractTableModel{
		
		public String getColumnName(int column) {
			return "Column" + column;
		}

		public int getRowCount() {
			return 10;
		}

		public int getColumnCount() {
			return 4;
		}

		public boolean isCellEditable(int row, int col) {
			return true;
		}
		
		public Object getValueAt(int rowIndex, int columnIndex) {
			if(columnIndex == 3){
				return new Boolean(true);
			}
			if(columnIndex == 2){
				return new Integer(rowIndex);
			}
			return rowIndex + "/" + columnIndex;
		}
		
		public Class<?> getColumnClass(int c) {
			return getValueAt(0, c).getClass();
		}
		
		
	}
	
	private String[] columnNames = { "A", "B", "C" };

	private Object[][] data = {
			{ "Value A1", new Integer(4),  new Boolean(false) },
			{ "Value A2", new Integer(3),  new Boolean(false) },
			{ "Value A3", new Integer(2),  new Boolean(false) },
			{ "Value A4", new Integer(50), new Boolean(false) },
			{ "Value A5", new Integer(42), new Boolean(false) }, };

	
	public SwingTableSimpleExample() {
		setTitle("My Frame"); 
		setSize(400, 150); 
		setLocationRelativeTo(null);
		JTable table = new JTable(data,columnNames);
		JScrollPane scrollPane = new JScrollPane(table);
		add(scrollPane);
		setVisible(true); 
	}

	public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
		UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
		new SwingTableSimpleExample();
	}

}

